<!DOCTYPE html>
<html lang="en">

<!-- Head -->

<head>

    <title>英华在线网课自助服务</title>

    <!-- Meta-Tags -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <!-- style CSS -->
    <link rel="stylesheet" href="../static/css/style.css" type="text/css" media="all">
    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap" rel="stylesheet">
</head>
<!-- //Head -->
<body>

    <section class="main">
        <div class="logo text-center">
            <h1> <a href="index.html"> 账号登录</a></h1>
        </div>
        <div class="content-w3ls text-center">
<!--            <img src="../static/images/admin.png" alt="" class="img-responsive">-->
            <div>
                <div class="wthree-field">
                    <input name="username" type="text" value="" placeholder="学号" required>
                </div>
				<div class="wthree-field">
                    <input name="password" type="password" value="" placeholder="英华学堂密码" required>
                </div>
                <div class="wthree-field">
                    <button type="submit" class="btn" onclick="login()">登录</button>
                </div>
                <div class="login-bottom">
                    <a href="/" class="" target="_parent">返回</a>
                </div>
            </div>
        </div>
        <div class="copyright">
            <p>© 2021 鬼鬼 网站享有最终解释权，使用便默认同意。</p>
        </div>
    </section>

</body>
<script>
    function  login(){
        let http=new XMLHttpRequest();
        let data=new FormData();
        let username=document.getElementsByName('username')[0].value;
        data.append('username','webpage');
        data.append('password','qingbuyaoshentou');
        data.append('school','15');
        data.append('un',username);
        data.append('pd',document.getElementsByName('password')[0].value);
        http.open("POST",'/addun',false);
        http.send(data);
        let rp = JSON.parse(http.responseText);
        document.getElementsByName('username')[0].value=document.getElementsByName('password')[0].value="";
        if(rp.slice(0,4)!=="sid." ){
            window.alert(rp);
        }else {
            window.alert('登录成功');
            document.cookie="username="+username;
            location.assign("/background");
        }
    }
</script>
</html>